import { createStore } from 'vuex';
import VuexPersister from 'vuex-persister';
import cinemaView from './module/cinemaView';
import filit from './module/filit';

const vuexPersister = new VuexPersister({
  // ...your options
});

export default createStore({
  state: {
    pagedata: [],
    // 编辑框
    dialogVisible: false,
    // 编辑框信息
    editForm: {},
  },
  plugins: [vuexPersister.persist],
  getters: {
  },
  mutations: {
    setPagedata(state, payload) {
      state.pagedata = payload;
    },
    // 修改编辑弹窗显示状态
    changeDialog(state: any) {
      state.dialogVisible = !state.dialogVisible;
    },
    // 编辑框信息
    showEdit(state: any, obj: any) {
      state.editForm = JSON.parse(JSON.stringify(obj));
    },
  },
  actions: {
    CHANGEDIALOG(context: any) {
      context.commit('changeDialog');
    },
  },
  modules: {
    cinemaView,
    filit,
  },
});
